#include "hal_trgmux.h"

/*******************************************************************************
 * Code
 ******************************************************************************/
void TRGMUX_SetTriggerSource(TRGMUX_Type *base,
                             trgmux_device_t index,
                             trgmux_trigger_input_t input,
                             trgmux_source_t trigger_src)
{
    uint32_t value;

    value = base->TRGCFG[index];
    /* Since all SEL bitfileds in TRGCFG register have the same length, SEL0's mask is used to access other SEL
    * bitfileds. */
    value = (value & ~((uint32_t)(TRGMUX_TRGCFG_SEL0_MASK << input))) |
            ((uint32_t)(((uint32_t)(trigger_src & TRGMUX_TRGCFG_SEL0_MASK)) << input));
    base->TRGCFG[index] = value;
}

/* EOF. */
